<?php
/**
 * author: JiangJun
 * CreateTime:2021/8/30 6:03 下午
 */

use Aws\Exception\AwsException;
use Aws\S3\S3Client;

require '../sqs/vendor/autoload.php';

$s3Client = new S3Client([
    'region' => 'ap-northeast-2',
    'version' => '2006-03-01'
]);

//不知道为什么会报错，不管了，创建bucket的功能不重要，在控制台上点点鼠标也能创建
function createBucket($s3Client, $bucketName)
{
    try {
        $result = $s3Client->createBucket([
            'Bucket' => $bucketName,
        ]);
        return 'The bucket\'s location is: ' .
            $result['Location'] . '. ' .
            'The bucket\'s effective URI is: ' .
            $result['@metadata']['effectiveUri'];
    } catch (AwsException $e) {
        return 'Error: ' . $e->getAwsErrorMessage();
    }
}

echo createBucket($s3Client,'jjvideo');